package javaCode;

/**
 * Created by lxy_920912 on 22/04/2017.
 */
public class LeetCode50 {
    public double myPow(double x, int n) {
        if(n == 0){
            return 1;
        }
        if(n < 0){
            n = -n;
            x = 1/x;
        }
        if(Math.abs(x - 0.0) < 0.e-10){
            return 0;
        }
        if( n % 2 == 0){
            return myPow(x*x,n/2);

        }else {
            return x * myPow(x*x,n/2);
        }
    }
}
